﻿using Orchard.MediaProcessing.Services;
using Orchard.Themes;
using System.Web.Mvc;
using Vitus.MediaProcessing.ViewModels;

namespace Vitus.MediaProcessing.Controllers
{
    public class AdminController : Controller
    {
        private readonly IImageProfileManager profileManager;

        public AdminController(IImageProfileManager profileManager)
        {
            this.profileManager = profileManager;
        }

        [Themed(false)]
        public ActionResult ImageProfilePreview(string mediaPath, string profileName)
        {
            var viewModel = new ImageProfilePreviewViewModel
                {
                    MediaPath = mediaPath,
                    ProfileName = profileName
                };

            return View(viewModel);
        }

        [Themed(false)]
        public ActionResult ImageProfileUrl(string mediaPath, string profileName)
        {
            string url = profileManager.GetImageProfileUrl(mediaPath, profileName);

            return Json(url, JsonRequestBehavior.AllowGet);
        }
    }
}